import request from '@/utils/request'
//解决数组传递问题
import qs from 'qs'
//搜索用户
export const reqUserList = (page,limit,username)=>{
 return request({
   url:`/admin/acl/user/${page}/${limit}`,
   method:'get',
   params: { username }
 })
}
//删除一个用户
export const reqDeleteOneUser = (id)=>{
 return request({
   url:`/admin/acl/user/remove/${id}`,
   method:'delete'
 })
}
//添加一个用户
export const reqAddUser = (data)=>{
 return request({
   url:'/admin/acl/user/save',
   method:'post',
   data,
 })
}
//修改用户
export const reqUpdateUser = (data)=>{
 return request({
   url:`/admin/acl/user/update`,
   method:'put',
   data,
 })
}
//批量删除
export const reqDeleteUsers = (data)=>{
 return request({
   url:'/admin/acl/user/batchRemove',
   method:'delete',
   data,
 })
}
//获取用户的角色
export const reqUserRole = (userId)=>{
 return request({
   url:`/admin/acl/user/toAssign/${userId}`,
   method:'get',
 })
}
//获取角色列表
export const reqRoles = ()=>{
 return request({
   url:`/admin/acl/role/1/22`,
   method:'get'
 })
}
//分配角色
export const reqDoAssign = (userId,roleId)=>{
  return request({
    url:`/admin/acl/user/doAssign`,
    method:'post',
    params: {
      userId,
      roleId,
    },
    //解决传递数组时出现的问题
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}
